//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package net.mingsoft.mdiy.action.web;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import net.mingsoft.base.entity.ResultData;
import net.mingsoft.base.util.SqlInjectionUtil;
import net.mingsoft.basic.action.BaseAction;
import net.mingsoft.basic.bean.EUListBean;
import net.mingsoft.basic.util.BasicUtil;
import net.mingsoft.mdiy.biz.IDictBiz;
import net.mingsoft.mdiy.entity.DictEntity;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import springfox.documentation.annotations.ApiIgnore;

@Api(
        tags = {"前端-自定义模块接口"}
)
@Controller("webDictAction")
@RequestMapping({"/mdiy/dict"})
public class DictAction extends BaseAction {
    @Autowired
    private IDictBiz dictBiz;

    public DictAction() {
    }

    @ApiOperation("查询字典表列表")
    @ApiImplicitParams({@ApiImplicitParam(
            name = "dictType",
            value = "类型",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "dictValue",
            value = "数据值",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "dictLabel",
            value = "标签名",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "dictSort",
            value = "排序（升序）",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "isChild",
            value = "子业务关联",
            required = false,
            paramType = "query"
    )})
    @GetMapping({"/list"})
    @ResponseBody
    public ResultData list(@ModelAttribute @ApiIgnore DictEntity dict, HttpServletResponse response, HttpServletRequest request) {
        SqlInjectionUtil.filterContent(new String[]{dict.getOrderBy()});
        dict.setSqlWhere("");
        if (dict != null && !StringUtils.isEmpty(dict.getDictType())) {
            BasicUtil.startPage(1, 100, true);
            dict.setDictEnable(true);
            List dictList = this.dictBiz.query(dict);
            return ResultData.build().success(new EUListBean(dictList, (int)BasicUtil.endPage(dictList).getTotal()));
        } else {
            return ResultData.build().error(this.getResString("dict.type"));
        }
    }

    @ApiOperation("查询字典表列表,排除站点编号")
    @ApiImplicitParams({@ApiImplicitParam(
            name = "dictValue",
            value = "数据值",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "dictLabel",
            value = "标签名",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "dictType",
            value = "类型",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "dictDescription",
            value = "描述",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "dictSort",
            value = "排序（升序）",
            required = false,
            paramType = "query"
    ), @ApiImplicitParam(
            name = "isChild",
            value = "子业务关联",
            required = false,
            paramType = "query"
    )})
    @GetMapping({"/listExcludeApp"})
    @ResponseBody
    public ResultData listExcludeApp(@ModelAttribute @ApiIgnore DictEntity dict, HttpServletResponse response, HttpServletRequest request) {
        SqlInjectionUtil.filterContent(new String[]{dict.getOrderBy()});
        dict.setSqlWhere("");
        dict.setDictEnable(true);
        List dictList = this.dictBiz.queryExcludeApp(dict);
        return ResultData.build().success(dictList);
    }
}
